import Vue from 'vue'
import Router from 'vue-router'

import Home from '@/components/tabbar/home'
import Member from '@/components/tabbar/member'
import Shop from '@/components/tabbar/shop'
import Search from '@/components/tabbar/search'

import NewsList from '@/components/news/NewsList'
import NewsDetail from '@/components/news/NewsDetail'

import PhotoList from '@/components/photo/PhotoList'
import PhotoInfo from '@/components/photo/PhotoInfo'

import ShopList from '@/components/shop/ShopList'
import ShopInfo from '@/components/shop/ShopInfo'
import ShopRecom from '@/components/shop/ShopRecom'
import ShopComment from '@/components/shop/ShopComment'

import JieSuan from '@/components/jiesuan/jiesuan'

import login from '@/components/login/login'
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      // 重定向
      redirect:'/home'
    },
    {
      path:'/login',
      name:'login',
      component:login
    },
    {
      path: '/home',
      component: Home,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path: '/member',
      component: Member,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path: '/shop',
      component: Shop,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path: '/search',
      component: Search,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path:'/home/newslist',
      component:NewsList,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      // 根据不同的id进不同的详情页
      path:'/home/newsdetail/:id',
      component:NewsDetail,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path:'/home/photolist',
      component:PhotoList,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path:'/home/photoinfo/:id',
      component:PhotoInfo,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path:'/home/shoplist',
      component:ShopList,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      name:'shopinfo',
      path:'/home/shopinfo/:id',
      component:ShopInfo,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      name:'shoprecom',
      path:'/home/shoprecom/:id',
      component:ShopRecom,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      name:'shopcomment',
      path:'/home/shopcomment/:id',
      component:ShopComment,
      meta: {
        req: true // 需要验证登录状态
      }
    },
    {
      path:'/shop/jiesuan',
      component:JieSuan,
      meta: {
        req: true // 需要验证登录状态
      }
    }
  ],
  // 使用前端路由，当切换到新路由时，想要页面滚到顶部，或者是保持原先的滚动位置，就像重新加载页面那样。
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  },
  // 高亮显示
  linkActiveClass:'mui-active'
})
